// import { books } from "@/mock/db"
import axios from "axios";

const baseUrl='http://localhost:8000'

export const addBook = async (obj) => {
  let res = await axios.post(`${baseUrl}/books`,obj)
  return res.data
}
export const delBook = async(id) => {
  let res = await axios.delete(`${baseUrl}/books/${id}`)
  return res.data
  
}
export const getAll = async () => {
  let res = await axios.get( `${baseUrl}/books`)
  // console.log(res);
  
  return res.data
}
export const getById = async (id) => {
  let res = await axios.get( `${baseUrl}/books/${id}`)
  // console.log(res);
  
  return res.data
}
export const editBook = async (id,obj) => {
  let res = await axios.put(`${baseUrl}/books/${id}`,obj)
  return res.data
}
export const find = async (keyword) => {
  let res = await axios.get( `${baseUrl}/books?keyword=${keyword}`)
  // console.log(res);
  
  return res.data
}